import { Generated } from 'kysely'

export const normalize = (str: string) => str.split(',').map(e => e.trim())

export interface Database {
  badges: Badge
  bots: Bot
  bots_api: BotsAPI
  bots_api_servers: BotsAPIServers
  bots_banned: BotsBanned
  bots_reasons: BotsReasons
  bumpsLog: BumpsLog
  comments: Comment
  comments_likes: CommentLike
  cooldowns: Cooldown
  donations: Donation
  libraries: Library
  moderStats: ModerStat
  notifications: Notification
  profiles: Profile
  promocodes: Promocode
  promocode_users: PromocodeUser
  refferal: Refferal
  reports: Report
  servers: Server
  servers_banned: ServersBan
  servers_comments: ServerComment
  shortCodes: ShortCode
  users_banned: UserBan
  users_boosts: UsersBoosts
  users_cache: UserCache
}

export interface Badge {
  id: Generated<number>
  border: string
  title: string
  path: string
}

export enum BotStatus {
  Pending,
  Rejected,
  Recheck,
  Accepted
}

export enum BotBadge {
  No,
  Tester,
  BugHunter,
  BugHunterElite,
  Partner,
  DevelopersBot
}

export interface Bot {
  id: Generated<number>
  botID: string
  http_interaction: number
  unlisted: number
  recheckBlock: number
  shortCode: string
  imageURL?: string
  prefix: string
  perms: bigint
  invite_only_from_site: number
  status: BotStatus
  statusReason?: string
  warning?: string
  tags: string
  developers: string
  donate?: number
  styleUse: number
  bannerInstall: number
  customizeCard: number
  hideDevelopers: number
  badge: BotBadge
  bumps: number
  bumpsCooldown?: number
  inviteCount: number
  api?: string
  serviceBot: number
  serviceText?: string
  servers: number
  shards: number
  users: number
  description: string
  about: string
  library?: string
  discord?: string
  github?: string
  site?: string
  webhook_url?: string
  webhook_key?: string
  linked_server?: string
}

export interface BotsAPI {
  id: Generated<number>
  botID: string
  api: string
}

export interface BotsAPIServers {
  id: Generated<number>
  botID: string
  serverID: string
}

export interface BotsBanned {
  botID: string
  reason: string
}

export interface BotsReasons {
  id: Generated<number>
  botID: string
  reason?: string
  time?: number
}

export interface BumpsLog {
  id: Generated<number>
  botID: string
  userID: string
  time: number
}

export interface Comment {
  id: Generated<number>
  likes?: number
  userID: string
  botID: string
  text?: string
  admin_text?: string
  admin_updated: number
  admin_updatedAt?: number
  admin_userID?: string
  vote: number
  updatedAt: number
  updated: number
}

export interface CommentLike {
  id: Generated<number>
  userID?: string
  entityType?: string
  entityID?: string
}

export interface Cooldown {
  id: Generated<number>
  botID: string
  userID: string
  upTime: string
  cooldownExpireTime: string
}

export interface Donation {
  id: Generated<number>
  uuid?: string
  qiwi?: string
  userID: string
  amount: string
  status: number
  forV2: number
  dontParse: number
}

export interface Library {
  id: Generated<number>
  name: string
  processedName: string
}

export interface ModerStat {
  id: Generated<string>
  accept: number
  decline: string
  reCheck: string
  botReportCheck: string
  serverReportCheck: string
}

export interface Notification {
  id: Generated<number>
  userID: string
  time?: number
  isRead: number
  isImportant: number
  type: string
  text: string
  link?: string
}

export interface Profile {
  id: Generated<string>
  donateBalance: number
  donate: number
  api?: string
  shortLinksAccess?: number
  refferal?: string
  styleUse: number
  location?: string
  hire: number
  status?: string
  about?: string
  editBlock: number
  linksAllowed?: number
  warning?: string
  commentsBanned: number
  badge?: number
  shortCode?: string
  site?: string
  donate_link?: string
  vk?: string
  steam?: string
  youtube?: string
  twitch?: string
  git?: string
}

export interface Promocode {
  code: string
  deactivated: number
  time?: number
  uses: number
  used: number
  eval?: string
  description?: string
  tooltip?: string
}

export interface PromocodeUser {
  id: Generated<number>
  userID: string
  code: string
}

export interface Refferal {
  code?: string
  ownerID?: string
  views: number
  adds_bots: number
  adds_servers: number
  rems_bots: number
  rems_servers: number
}

export enum EntityType {
  Bot,
  BotComment,
  Server,
  ServerComment,
}

export enum ReportStatus {
  Pending,
  Rejected,
  MoreInfo,
  Accepted
}

export interface Report {
  id: Generated<number>
  userID: string
  entityType: EntityType
  entityID: string
  reason?: string
  status: ReportStatus
  moderID?: string
}

export enum ServerStatus {
  NotOnServer,
  IsOnServer
}

export interface Server {
  id: Generated<number>
  serverID: string
  serviceServer: number
  status: ServerStatus
  shortCode?: string
  serverName?: string
  serverAvatar?: string
  serverMembersAllCount?: number
  serverMembersOnlineCount?: number
  serverOwnerID?: string
  serverOwnerTag?: string
  imageURL?: string
  tags?: string
  warning?: string
  donate?: number
  styleUse: number
  bannerInstall: number
  customizeCard: number
  badge: BotBadge
  bumps: number
  bumpsCooldown?: number
  description: string
  invite?: string
  about: string
  site?: string
  youtube?: string
  twitch?: string
  steam?: string
  vk?: string
  webhook_url?: string
  webhook_key?: string
  linked_bot?: string
}

export interface ServersBan {
  serverID: string
  reason: string
}

export interface ServerComment {
  id: Generated<number>
  likes: number
  userID: string
  serverID: string
  text?: string
  admin_text?: string
  admin_updated: number
  admin_updatedAt?: number
  admin_userID?: string
  vote: number
  updated: number
  updatedAt: number
}

export enum ShortCodeDomain {
  All,
  BcordCC,
  MyServersMe,
  DiscordCamp
}

export interface ShortCode {
  id: Generated<number>
  code: string
  ownerID?: string
  domain: ShortCodeDomain
  views: number
  link: string
  data?: string
}

export interface UserBan {
  banID: string
  userIID: string
  reason?: string
}

export interface UsersBoosts {
  dbID: Generated<number>
  id: string
  type: 1 | 2
  ownerID?: string
  resetTime?: number
}

export interface UserCache {
  id: string
  tag: string
  avatar?: string
  cache_guilds?: string
}